#pragma once

#include "Containers/String.h"


//typical  url is : protocol://hostname[:port]/path/[?query]#fragment
struct CUrl
{
public:
    class CQuery
    {
    public:
        CString Key;
        CString Value;
    };

    CUrl();
    ~CUrl();

    CString GetProtocol() const;
    CString GetHost() const;
    CString GetPath() const;
    TVector<CQuery>  GetQuerys() const;
    CString GetFragment() const;
    uint16_t GetPort() const;

    bool IsValid() const;

    //return true if the url is valid
    bool Parse(const CString& InUrl);

    static TOptional<CUrl> Create(const CString& InUrl);
protected:

    CString Url;
    CString Protocol;
    CString Host;
    CString Path;
    TVector<CQuery> Querys;
    CString Fragment;
    uint16_t Port = 0;

};